package view;
import interfaces.IConstants;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AltaPlanGeneralAdicional extends javax.swing.JFrame implements IConstants {

	private static final long serialVersionUID = 1L;
	private AltaPlanGeneralAdicional instancia; 
	private JButton Cancelar;
	private JButton Aceptar;
	private JComboBox PermiteExcedentecmbox;
	private JLabel PermiteExcedente;
	private boolean permiteExcedente = true;
	private JTextField Nombretxt;
	private JLabel Nombre;

	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				AltaPlanGeneralBase inst = new AltaPlanGeneralBase();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public AltaPlanGeneralAdicional() {
		super();
		initGUI();
		instancia = this;
		this.setTitle("Alta Plan Adicional");
		{
			Nombre = new JLabel();
			getContentPane().add(Nombre);
			Nombre.setText(IConstants.LABEL_NAME);
			Nombre.setBounds(43, 34, 125, 16);
		}
		{
			Nombretxt = new JTextField();
			getContentPane().add(Nombretxt);
			Nombretxt.setBounds(168, 31, 169, 23);
		}
		{
			PermiteExcedente = new JLabel();
			getContentPane().add(PermiteExcedente);
			PermiteExcedente.setText(IConstants.LABEL_PERMIT);
			PermiteExcedente.setBounds(43, 90, 125, 16);
		}
		{
			ComboBoxModel PermiteExcedentecmboxModel = new DefaultComboBoxModel(new String[] {CONST_YES, CONST_NO});
			PermiteExcedentecmbox = new JComboBox();
			getContentPane().add(PermiteExcedentecmbox);
			PermiteExcedentecmbox.setModel(PermiteExcedentecmboxModel);
			PermiteExcedentecmbox.setBounds(168, 87, 169, 23);			
		}
		{
			Aceptar = new JButton();
			getContentPane().add(Aceptar);
			Aceptar.setText("Agregar Servicio");
			Aceptar.setBounds(77, 154, 137, 23);
			Aceptar.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					String selectedItem = (String) PermiteExcedentecmbox.getSelectedItem();
					if (selectedItem != null) {
						if (selectedItem.equals(CONST_YES)) {
							permiteExcedente = true;
						}
						else if (selectedItem.equals(CONST_NO)) {
							permiteExcedente = false;
						}
					}
					
					AltaPlanAdicional app = new AltaPlanAdicional(Nombretxt.getText().trim(), permiteExcedente);
					app.setLocationRelativeTo(null);
					app.setVisible(true);
					instancia.setVisible(false);
				}
			});
		}
		{
			Cancelar = new JButton();
			getContentPane().add(Cancelar);
			Cancelar.setText("Cancelar");
			Cancelar.setBounds(219, 154, 82, 23);
			Cancelar.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					Menu app = new Menu();
					app.setLocationRelativeTo(null);
					app.setVisible(true);
					instancia.dispose();
				}
			});
		}
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			pack();
			this.setSize(372, 237);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	private void limpiarCampos(){
		Nombretxt.setText(null);
	}

}
